﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lidgren.Network;
using Microsoft.Xna.Framework;

namespace uam_fps_game.Network.MessageTypes
{
    class SendMessageToSmb : MessagePrototype
    {
        string text;
        string senderName;
        string receiverName;

        public SendMessageToSmb(string senderName, string receiverName, string text)
        {
            this.senderName = senderName;
            this.receiverName = receiverName;
            this.text = text;
        }

        public static Letter ParseMessage(NetIncomingMessage msg)
        {
           // System.Text.Encoding enc = System.Text.Encoding.ASCII;
           // byte[] sname = msg.ReadBytes(sizeof(char) * 12);
           // byte[] rname = msg.ReadBytes(sizeof(char) * 12);

            Letter letter = new Letter();
            letter.senderName = msg.ReadString();
            letter.receiverName = msg.ReadString();
            letter.text = msg.ReadString();
            return letter;
        }

        public override void CreateMessage(ref NetOutgoingMessage om)
        {
            //System.Text.ASCIIEncoding  encoding = new System.Text.ASCIIEncoding();
           // byte[] sname = encoding.GetBytes(this.senderName.Substring(0,12));
           // om.Write(sname);
           // byte[] rname = encoding.GetBytes(this.receiverName.Substring(0, 12));
            om.Write(this.senderName);
            om.Write(this.receiverName);
            om.Write(this.text);
        }
    }
}

